1 using ExitGames.Client.Photon;
2 using
UnityEngine;
3 using
System.Collections;
4
5 [RequireComponent(
typeof(PhotonView))]
6 public
class OnAwakeUsePhotonView : Photon.MonoBehaviour {
7
8     
// tries to send an RPC as soon as this script awakes (e.g. immediately when instantiated)
9     
void Awake()
10     {
11         
if (!this.photonView.isMine)
12         {
13             
return;
14         }
15
16         
// Debug.Log("OnAwakeSendRPC.Awake() of " + this + " photonView: " + this.photonView + " this.photonView.instantiationData: " + this.photonView.instantiationData);
17         
this.photonView.RPC("OnAwakeRPC", PhotonTargets.All);
18     }
19
20     
// tries to send an RPC as soon as this script starts (e.g. immediately when instantiated)
21     
void Start()
22     {
23         
if (!this.photonView.isMine)
24         {
25             
return;
26         }
27
28         
// Debug.Log("OnAwakeSendRPC.Start() of " + this + " photonView: " + this.photonView);
29         
this.photonView.RPC("OnAwakeRPC", PhotonTargets.All, (byte)1);
30     }
31     
32     
[RPC]
33     
public void OnAwakeRPC()
34     {
35         Debug.Log(
"RPC: 'OnAwakeRPC' PhotonView: " + this.photonView);
36     }
37
38     
[RPC]
39     
public void OnAwakeRPC(byte myParameter)
40     {
41         Debug.Log(
"RPC: 'OnAwakeRPC' Parameter: " + myParameter + " PhotonView: " + this.photonView);
42     }
43 }


tries to send an RPC as soon as this script awakes (e.g. immediately when instantiated)

Debug.Log("OnAwakeSendRPC.Awake() of " + this + " photonView: " + this.photonView + " this.photonView.instantiationData: " + this.photonView.instantiationData);

tries to send an RPC as soon as this script starts (e.g. immediately when instantiated)

Debug.Log("OnAwakeSendRPC.Start() of " + this + " photonView: " + this.photonView);




Trò chơi Tic-Tac-Toe, game đánh caro full source code 53.513 lượt xem

Gõ tìm kiếm nhanh...